<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="68px"
    >
      <div class="shuxing">
        <el-form-item label="行政区域" prop="areaId">
          <treeselect
            class="shuxing1"
            v-model="queryParams.areaId"
            :options="areaList"
            :normalizer="normalizer"
            placeholder="选择区域"
          />
        </el-form-item>
      </div>
      <el-form-item label="主体名称" prop="enterName">
        <el-input
          v-model="queryParams.enterName"
          placeholder="请输入主体名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="基地名称" prop="baseName">
        <el-input
          v-model="queryParams.baseName"
          placeholder="请输入基地名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="plantProcessInfoList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        label="序号"
        align="center"
        type="index"
        :index="indexMethod"
        width="80"
      />
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主体名称" align="center" prop="enterName" />
      <el-table-column label="基地名称" align="center" prop="baseName" />
      <el-table-column label="种植作物类型" align="center" prop="plantType" />
      <el-table-column label="种植面积" align="center" prop="plantArea" />
      <el-table-column label="种植单位" align="center" prop="plantUnit" />
      <el-table-column
        label="投品购买批次号"
        align="center"
        prop="purchaseBatchNum"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width" width="280px"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['TPlantProcessInfo:plantProcessInfo:edit']"
            >详情</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleAdd1(scope.row, 1)"
            v-hasPermi="['TPlantProcessInfo:plantProcessInfo:remove']"
            >化肥使用记录</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleAdd1(scope.row, 2)"
            v-hasPermi="['TPlantProcessInfo:plantProcessInfo:remove']"
            >农药使用记录</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改种植管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="60%" append-to-body>
      <div class="add">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-form-item label="基地名称" prop="baseName">
            <el-input v-model="form.baseName" placeholder="" />
          </el-form-item>
          <el-form-item label="种植作物类型">
            <el-select
              v-model="form.plantType"
              placeholder="番茄（别名：西红柿，洋柿子）"
            >
              <el-option label="请选择字典生成" value="" />
            </el-select>
          </el-form-item>
          <div class="add-box">
            <el-form-item label="种植面积" prop="plantArea">
              <el-input v-model="form.plantArea" placeholder="请输入种植面积" />
            </el-form-item>
            <el-form-item label="种植面积单位" prop="plantUnit">
              <el-input v-model="form.plantUnit" placeholder="请输入种植单位" />
            </el-form-item>
            <el-form-item label="种植日期" prop="plantTime">
              <el-input v-model="form.plantTime" placeholder="请输入种植日期" />
            </el-form-item>
            <el-form-item label="生长期" prop="growthPeriod">
              <el-input
                v-model="form.growthPeriod"
                placeholder="请输入生长期"
              />
            </el-form-item>
            <el-form-item label="生长期单位" prop="growthPeriodUnit">
              <el-input
                v-model="form.growthPeriodUnit"
                placeholder="请输入生长期单位"
              />
            </el-form-item>
            <el-form-item label="预估成熟期" prop="estimatedMaturity">
              <el-input
                v-model="form.estimatedMaturity"
                placeholder="请输入预估成熟期"
              />
            </el-form-item>
          </div>
          <el-form-item label="种苗来源">
            <el-radio-group v-model="form.resource">
              <el-radio label="自产种苗"></el-radio>
              <el-radio label="采购种苗"></el-radio>
              <el-radio label="购买种子"></el-radio>
            </el-radio-group>
          </el-form-item>
          <div class="add-box">
            <el-form-item label="种苗名称" prop="plantName">
              <el-input v-model="form.plantName" placeholder="请输入种苗名称" />
            </el-form-item>
            <el-form-item label="种苗数量" prop="plantNum">
              <el-input v-model="form.plantNum" placeholder="请输入种苗数量" />
            </el-form-item>
            <el-form-item label="种苗单位" prop="plantUnits">
              <el-input
                v-model="form.plantUnits"
                placeholder="请输入种苗单位"
              />
            </el-form-item>
            <el-form-item label="种苗经营企业" prop="plantCompany">
              <el-input
                v-model="form.plantCompany"
                placeholder="请输入种苗经营公司"
              />
            </el-form-item>
            <el-form-item label="种苗生产经营许可证照片" prop="licenceImg">
              <div v-for="(item, index) in list" :key="index" class="listimg">
                <img :src="item" />
              </div>
            </el-form-item>
            <el-form-item label="" prop=""> </el-form-item>
          </div>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 化肥使用记录对话框 -->
    <el-dialog :title="title1" :visible.sync="open1" width="60%" append-to-body>
      <el-form :inline="true" label-width="68px">
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd2"
            v-hasPermi="['TPlantProcessInfo:plantProcessInfo:add']"
            >新增</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        v-loading="loading"
        :data="plantProcessInfoList1"
        @selection-change="handleSelectionChange"
        class="huafei"
      >
        <el-table-column
          label="序号"
          align="center"
          type="index"
          :index="indexMethod"
          width="80"
        />
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="基地名称" align="center" prop="baseName" />
        <el-table-column
          :label="tableNAme"
          align="center"
          prop="purchaseName"
        />
        <el-table-column label="使用量" align="center" prop="useAge" />
        <el-table-column
          label="投入品批次号"
          align="center"
          prop="recordBatc"
        />
        <el-table-column label="使用时间" align="center" prop="recordTime" />
        <el-table-column label="同步状态" align="center" prop="syncStatus" />
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdatehua(scope.row)"
              v-hasPermi="['TPlantProcessInfo:plantProcessInfo:edit']"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleUpdatexiang(scope.row)"
              v-hasPermi="['TPlantProcessInfo:plantProcessInfo:remove']"
              >详情</el-button
            >
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDeleteHua(scope.row)"
              v-hasPermi="['TPlantProcessInfo:plantProcessInfo:remove']"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-dialog>

    <!-- 化肥使用记录新增修改 -->
    <el-dialog
      :title="title2"
      :visible.sync="open2"
      width="60%"
      append-to-body
      :closeOnPressEscape="showClo"
      :show-close="showClo"
    >
      <div class="add">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <div class="add-box">
            <!--la -->
            <el-form-item :label="tableNAme">
              <el-select v-model="form2.selects" placeholder="请选择">
                <el-option label="请选择"  value="请选择"  ></el-option>
                <el-option
                  v-for="(item, index) in purchaseInfoList"
                  :label="item.purchaseName"
                  :key="index"
                  :value="item.purchaseName"
                ></el-option>
              </el-select>
            </el-form-item>
            <!-- la -->
            <el-form-item label="投入品批次号">
              <el-input
                v-model="form2.query.batchNum"
                placeholder="投入品批次号"
                readonly
              />
            </el-form-item>

            <!-- zhu -->
            <el-form-item label="主体名称" prop="plantArea">
              <el-input
                v-model="form2.index.enterName"
                placeholder="请输入主体名称"
                readonly
              />
            </el-form-item>
            <!-- la -->
            <el-form-item label="投入品追溯码" prop="plantUnit">
              <el-input
                v-model="form2.query.traceCode"
                placeholder="请输入投入品追溯码"
                readonly
              />
            </el-form-item>
            <!-- zhu -->
            <el-form-item label="种植时间" prop="plantTime">
              <el-input
                v-model="form2.index.plantTime"
                placeholder="请输入种植时间"
                readonly
              />
            </el-form-item>
            <!-- zhu -->
            <el-form-item label="基地名称" prop="growthPeriod">
              <el-input
                v-model="form2.index.baseName"
                placeholder="请输入生长期"
                readonly
              />
            </el-form-item>
            <!-- zhu -->
            <el-form-item label="基地编号" prop="growthPeriodUnit">
              <el-input
                v-model="form2.query.baseCode"
                placeholder="请输入生长期单位"
                readonly
              />
            </el-form-item>
            <!-- zhu -->
            <el-form-item label="种植面积" prop="estimatedMaturity">
              <el-input
                v-model="form2.index.plantArea"
                placeholder="请输入预估成熟期"
                readonly
              />
            </el-form-item>

            <!-- zhu -->
            <el-form-item label="面积单位" prop="plantName">
              <el-input
                v-model="form2.index.plantUnit"
                placeholder="请输入种苗名称"
                readonly
              />
            </el-form-item>
            <!-- zhu -->
            <el-form-item label="作物名称" prop="plantNum">
              <el-input
                v-model="form2.index.plantName"
                placeholder="请输入种苗数量"
                readonly
              />
            </el-form-item>
            <!-- la -->
            <el-form-item label="购买数量" prop="plantUnits">
              <el-input
                v-model="form2.query.purchaseUnit"
                placeholder="请输入种苗单位"
                readonly
              />
            </el-form-item>

            <!-- la-->
            <el-form-item label="化肥单位" prop="plantCompany">
              <el-input
                v-model="form2.query.purchaseNumber"
                placeholder="请输入种苗经营公司"
                readonly
              />
            </el-form-item>
            <!-- 自己写 -->
            <el-form-item label="使用量（亩）" prop="plantCompany">
              <el-input
                v-model="form2.query.useAge"
                placeholder="请输入种苗经营公司"
              />
            </el-form-item>
            <!-- la -->
            <el-form-item label="使用单位" prop="plantCompany">
              <el-input
                v-model="form2.query.purchaseUnit"
                placeholder="请输入种苗经营公司"
                readonly
              />
            </el-form-item>
            <!-- 自己写 -->
            <el-form-item label="使用时间" prop="plantCompany">
              <div class="block">
                <span class="demonstration"></span>
                <el-date-picker
                  v-model="form2.query.otime"
                  type="date"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </div>
            </el-form-item>

            <el-form-item label="" prop=""> </el-form-item>
          </div>
          <el-form-item
            label="农事活动照片上传"
            prop="licenceImg"
            label-width="130px"
          >
            <el-upload
              class="upload-demo"
              action="https://jsonplaceholder.typicode.com/posts/"
              multiple
              :limit="3"
            >
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">
                只能上传jpg/png文件，且不超过500kb
              </div>
            </el-upload>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button  type="primary" @click="submitFormHua">确 定</el-button>
        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPlantProcessInfo,
  getPlantProcessInfo,
  delPlantProcessInfo,
  addPlantProcessInfo,
  getHuafeiInfo,
  updatePlantProcessInfo,
  exportPlantProcessInfo,
  listPurchaseInfo,
  addPlantProcessInfoHua,
  delPlantProcessInfoHua,
  getHuafeiInfoedit,updatePlantProcessInfoHua
} from "@/api/TPlantProcessInfo/plantProcessInfo";
import {
  getTree,
  listEnterpriseInfo,
} from "@/api/enterpriseInfo/EnterpriseInfo";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "PlantProcessInfo",
  components: { Treeselect },
  watch: {
    "form2.selects": function () {
      for (let i = 0; i < this.purchaseInfoList.length; i++) {
        if (this.purchaseInfoList[i].purchaseName == this.form2.selects) {
          this.form2.query = this.purchaseInfoList[i];
        }
        else{
          this.form2.query=[];
        }
      }
    },
  },
  data() {
    return {
      // 详情取消
      showif:true,
      showClo: false,
      //种苗经营许可证照片
      list: [
        "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
      ],
      // 列表中的化肥，农药列
      tableNAme: "化肥",
      // 详情单选
      radio: "自产种苗",
      // 序号
      indexMethod(index) {
        return index + 1;
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,

      areaList: [],
      // 总条数
      total: 0,
      // 种植管理表格数据
      plantProcessInfoList: [],
      // 化肥或农药管理表格数据
      plantProcessInfoList1: [],
      // 弹出层标题
      title: "",
      // 化肥弹出层标题
      title1: "",
      // 弹出添加修改弹出层标题
      title2: "",
      // 化肥id
      huaid: "",
      huaName: "",
      // 是否显示弹出层
      open: false,
      // 是否显示化肥使用记录
      open1: false,
      // 是否显示化肥新增和修改
      open2: false,

      // 种植主体返回信息
      purchaseInfoList: [],
     
      // 查询种植主体管理列表
      queryParams2: {
        pageNum: 1,
        pageSize: 1000,
        areaId: undefined,
        purchaseType: undefined,
        batchNum: undefined,
        purchaseTime: undefined,
        purchaseName: undefined,
        purchaseNumber: undefined,
        purchaseUnit: undefined,
        traceCode: undefined,
        enterId: undefined,
        enterName: undefined,
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        enterName: undefined,
        areaId: undefined,
        baseName: undefined,
        baseId: undefined,
        plantType: undefined,
        plantArea: undefined,
        plantUnit: undefined,
        plantTime: undefined,
        growthPeriod: undefined,
        growthPeriodUnit: undefined,
        estimatedMaturity: undefined,
        plantSource: undefined,
        plantName: undefined,
        plantNum: undefined,
        plantUnits: undefined,
        plantCompany: undefined,
        licenceImg: undefined,
      },
      // 化肥查询参数
      queryParams1: {
        plantProcessId: undefined,
        areaId: undefined,
        baseName: undefined,
      },
      // 主单页列表
      index: "",
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      // 添加化肥使用记录参数
      form2: {
         selects: "请选择",
        // 化肥新增时下拉菜单返回值
        query: [],

        hand: [],
        // 主页面返回
        index: [],
        // 时间
        otime: "",
      },
    };
  },
  created() {
    this.getList();
    this.getTreeList();
  },
  methods: {
    /** 查询种植管理列表 */
    getList() {
      this.loading = true;
      listPlantProcessInfo(this.queryParams).then((response) => {
        this.plantProcessInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getTreeList() {
      getTree().then((response) => {
        this.areaList = this.handleTree(response.data, "id");
      });
    },
    /** 转换部门数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.label,
        children: node.children,
      };
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 化肥添加修改取消按钮
    cancel2() {
      this.selects = "请选择";
      (this.form2 = {
        // 化肥新增时下拉菜单返回值
        query: [],

        hand: [],
        // 主页面返回
        index: this.index,
        // 时间
        otime: "",
      }),
        (this.open2 = false);
      this.reset();
    },
    // 农药添加修改取消按钮
    cancel4() {
      this.open4 = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        baseId: undefined,
        plantType: undefined,
        plantArea: undefined,
        plantUnit: undefined,
        plantTime: undefined,
        growthPeriod: undefined,
        growthPeriodUnit: undefined,
        estimatedMaturity: undefined,
        plantSource: undefined,
        plantName: undefined,
        plantNum: undefined,
        plantUnits: undefined,
        plantCompany: undefined,
        licenceImg: undefined,
      };
      this.resetForm("form");
    },
    // 农业重置
    reset1() {
      this.form = {
        id: undefined,
        baseId: undefined,
        plantType: undefined,
        plantArea: undefined,
        plantUnit: undefined,
        plantTime: undefined,
        growthPeriod: undefined,
        growthPeriodUnit: undefined,
        estimatedMaturity: undefined,
        plantSource: undefined,
        plantName: undefined,
        plantNum: undefined,
        plantUnits: undefined,
        plantCompany: undefined,
        licenceImg: undefined,
      };
      this.resetForm("form");
    },
    // 化肥重置
    reset2() {
      this.form = {
        id: undefined,
        baseId: undefined,
        plantType: undefined,
        plantArea: undefined,
        plantUnit: undefined,
        plantTime: undefined,
        growthPeriod: undefined,
        growthPeriodUnit: undefined,
        estimatedMaturity: undefined,
        plantSource: undefined,
        plantName: undefined,
        plantNum: undefined,
        plantUnits: undefined,
        plantCompany: undefined,
        licenceImg: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 农药及化肥搜索
    handleQuery1() {
      this.queryParams1.pageNum = 1;
      this.getList1();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加种植管理";
    },
    /** 化肥使用记录打开窗口 */
    handleAdd1(row, str) {
      // 初始化
      if (str == 1) {
        this.tableNAme = "化肥名称";
        this.title1 = "化肥使用记录";
        this.huaName = 1;
      } else {
        this.huaName = 2;
        this.tableNAme = "农药名称";
        this.title1 = "农药使用记录";
      }
      this.huaid = row.id || this.ids;
      (this.index = row);
      this.queryParams1 = {
        areaId: undefined,
        baseName: undefined,
        plantProcessId: this.huaid,
      };
      this.reset1();
      this.getList1();
      this.open1 = true;
    },
    /** 化肥使用添加打开窗口 */
    handleAdd2(row) {
      this.nongid=undefined;
      if (this.title1 == "化肥使用记录") {
        this.title2 = "添加化肥使用记录";
      } else {
        this.title2 = "添加农药使用记录";
      }
      this.form2.index = this.index;
      this.form2.hand = row;
      this.form2.query = [];
      this.form2.selects="请选择";
      this.open2 = true;
      this.getListzhu();
    },
    /** 化肥使用修改操作 */
    handleUpdatehua(row) {
       if (this.title1 == "化肥使用记录") {
        this.title2 = "修改化肥使用记录";
      } else {
        this.title2 = "修改农药使用记录";
      }
      const id = row.id || this.ids;
      this.nongid=id;
      getHuafeiInfoedit(id).then((response) => {
        this.form2.index = this.index;
        this.form2.query = response.data;
        this.form2.query.batchNum = response.data.recordBatc;
        this.form2.query.otime = response.data.recordTime;
        this.form2.selects = response.data.purchaseName;
        this.getListzhu();
        this.open2 = true;
          this.showif=true;
      });
    },
    handleUpdatexiang(row){
        if (this.title1 == "化肥使用记录") {
        this.title2 = "化肥使用记录详情";
        } else {
          this.title2 = "修改农药使用记录详情";
        }
        const id = row.id || this.ids;
        this.nongid=id;
        getHuafeiInfoedit(id).then((response) => {
          this.form2.index = this.index;
          this.form2.query = response.data;
          this.form2.query.batchNum = response.data.recordBatc;
          this.form2.query.otime = response.data.recordTime;
          this.form2.selects = response.data.purchaseName;
          this.getListzhu();
          this.open2 = true;
          this.showif=false;
        });
    },
    // 化肥使用记录提交按钮
    submitFormHua: function () {
         this.$refs["form"].validate((valid) => {
        if (valid) {
          let huaadd = {
              plantProcessId: this.huaid,
              recordType: this.huaName,
              useAge: this.form2.query.useAge,
              recordBatc: this.form2.query.batchNum,
              recordTime: "",
              syncStatus: "同步成功",
            };
            let otime = new Date(this.form2.query.otime);
            let oyear = otime.getFullYear();
            let omouth = otime.getMonth() + 1;
            let oday = otime.getDate();
            let otime1 = oyear + "-" + omouth + "-" + oday;
            huaadd.recordTime = otime1;
          if (this.nongid != undefined) {
            if(this.showif)
           {
              huaadd.id=this.nongid;
                    updatePlantProcessInfoHua(huaadd).then((response) => {
                    if (response.code == 0) {
                      this.msgSuccess("修改成功");
                      this.nongid=undefined;
                      this.open2 = false;
                      this.getList1();
                    }
                  });
            }
            else{
                this.open2 = false;
            }


          } else {
            addPlantProcessInfoHua(huaadd).then((response) => {
              if (response.code == 0) {
                this.msgSuccess("新增成功");
                this.open2 = false;
                this.getList1();
              }
            });
          }
        }
      });


     
    },
    /** 删除按钮操作 */
    handleDeleteHua(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除种植管理编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delPlantProcessInfoHua(ids);
        })
        .then(() => {
          this.getList1();
          this.msgSuccess("删除成功");
        })
        .catch(function () {});
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getPlantProcessInfo(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改";
      });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != undefined) {
            this.open = false;
          } else {
            addPlantProcessInfo(this.form).then((response) => {
              if (response.code == 0) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除种植管理编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delPlantProcessInfo(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(function () {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有种植管理数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportPlantProcessInfo(queryParams);
        })
        .then((response) => {
          this.download(response.data);
        })
        .catch(function () {});
    },

    // 查询农药和化肥管理列表
    getList1() {
      this.loading = true;
      getHuafeiInfo(this.queryParams1, this.huaName).then((response) => {
        this.plantProcessInfoList1 = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询种植主体管理列表 */
    getListzhu() {
      listPurchaseInfo(this.queryParams2).then((response) => {
        this.purchaseInfoList = response.rows;
        this.total = response.total;
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.shuxing {
  width: 250px;
  float: left;
  .shuxing1 {
    width: 150px !important;
    height: 35px;
  }
}
.add .el-form-item {
  width: 100%;
}
.add {
  width: 100%;
  .el-form .add-box {
    .el-form-item {
      width: 47%;
    }
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
  }
}
.el-select {
  width: 100%;
}
.listimg {
  width: 100%;
  img {
    width: 150px;
    height: 150px;
    margin-left: 5px;
    float: left;
  }
}
</style>